// 权限管理模块接口
import http from './servies'

// 获取角色列表
export function getRolesApi() {
  return http({
    url: 'roles',
    method: 'get'
  })
}

// 添加角色
export function addRoleApi(data:any) {
  return http({
    url: 'roles',
    method: 'post',
    data
  })
}

// 根据ID获取角色信息
export function getRolesByIdApi(id:number) {
  return http({
    url: 'roles/' + id,
    method: 'get'
  })
}

// 编辑提交角色
export function editRolesApi(id:number, data:any) {
  return http({
    url: 'roles/' + id,
    method: 'put',
    data
  })
}

// 删除角色
export function delRolesApi(id:number) {
  return http({
    url: 'roles/' + id,
    method: 'delete'
  })
}

// 获取权限列表
export function getRightsListApi(type: string) {
  return http({
    url: 'rights/' + type,
    method: 'get'
  })
}

// 角色授权
export function setRolesRightsApi(roleid: number, data: any) {
  return http({
    url: 'roles/' + roleid + '/rights',
    method: 'post',
    data
  })
}

// 删除角色指定授权
export function delRolesRightsApi(roleid: number, rightid: number) {
  return http({
    url: 'roles/' + roleid + '/rights/' + rightid,
    method: 'delete'
  })
}